package com.cy.hui_jie_dan.popj.entity;

import lombok.Data;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.time.Instant;

@Data
@Accessors(chain = true)
public class ChatMessage implements Serializable {
    private static final long serialVersionUID = 1L;
    
    private String messageId;  // Changed to String for Redis key compatibility
    private Integer fromUserId;
    private Integer toUserId;
    private String content;
    private Integer contentType; // 0-文本，1-图片URL
    private String imageUrl;
    private Integer status;  // 0-未读，1-已读，2-已删除，3-已撤回
    private Boolean recalled;
    private Instant createTime;
    private Instant updateTime;
    
    // Redis key generation methods
    @JsonIgnore
    public String getMessageKey() {
        return "chat:message:" + messageId;
    }
    
    @JsonIgnore
    public String getHistoryKey() {
        return "chat:history:" + fromUserId + ":" + toUserId;
    }
    
    @JsonIgnore
    public String getUnreadKey() {
        return "chat:unread:" + toUserId + ":" + fromUserId;
    }
}